package home.sockets.controller.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: Evgeny
 * Date: 10.09.13
 * Time: 23:37
 * To change this template use File | Settings | File Templates.
 */
public enum SpringFactory
{
    XML_INSTANCE
            {
                private ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
                @Override
                public <T> T getBean(Class<T> clazz)
                {
                    return getBeanByName(clazz.getName(), clazz);
                }

                @Override
                public <T> T getBeanByName(String name, Class<T> clazz)
                {
                    return context.getBean(name, clazz);
                }

            };
    public abstract <T> T getBean(Class<T> clazz);
    public abstract <T> T getBeanByName(String name, Class<T> clazz);


}
